"""
Examples of how to use the DIL_Frame component registry system.

This file demonstrates registration, creation, and usage of components.
"""

from learners.registry import (
    register_learner,
    register_training_strategy,
    register_drift_compensation,
    register_multi,
    create_learner,
    create_training_strategy,
    list_training_strategies,
)

from learners.interfaces import (
    LearnerInterface,
    TrainingInterface,
    DriftCompensationInterface,
)


# Example 1: Register a learner
@register_learner()  # Uses class name as registration name
class ExampleLearner(LearnerInterface):
    def __init__(self, args, data_manager, model_func):
        self.args = args
        self.data_manager = data_manager
        self.model_func = model_func
        print("ExampleLearner created")


# Example 2: Register with custom name
@register_learner("custom_learner")  # Uses "custom_learner" as registration name
class VerySpecificLearner(LearnerInterface):
    def __init__(self, args, data_manager, model_func):
        self.args = args
        self.data_manager = data_manager
        self.model_func = model_func
        print("VerySpecificLearner created as 'custom_learner'")


# Example 3: Register a training strategy
@register_training_strategy()
class ExampleTrainingStrategy(TrainingInterface):
    def __init__(self, **kwargs):
        self.kwargs = kwargs
        print("ExampleTrainingStrategy created")

    def train(self, model, data):
        print(f"Training with {self.__class__.__name__}")
        # Training logic


# Example 4: Multi-registration for hybrid components
@register_multi(
    register_drift_compensation("example_drift"),
    register_training_strategy("hybrid_strategy"),
)
class HybridComponent(DriftCompensationInterface, TrainingInterface):
    def __init__(self, **kwargs):
        self.kwargs = kwargs
        print("HybridComponent created")

    # Methods for both drift compensation and training


# Example 5: Usage in application code
def example_usage():
    # Create a learner
    learner = create_learner(
        "examplelearner",
        {"device": "cpu"},
        "data_manager_placeholder",
        "model_func_placeholder",
    )

    # Create a training strategy
    strategy = create_training_strategy("exampletrainingstrategy")

    # List available components
    print(f"Available training strategies: {list_training_strategies()}")

    print(f"Created learner: {learner.__class__.__name__}")
    print(f"Created training strategy: {strategy.__class__.__name__}")


if __name__ == "__main__":
    example_usage()
